﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WebApi.Models.Common;
using WebApi.Models.Views.Account;
using WebApi.Services.Interface;

namespace WebApi.Controllers
{
    /// <summary>
    /// 测试控制器
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class DemoController : ControllerBase
    {
        IDemoService _demoService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="demoService"></param>
        public DemoController(IDemoService demoService)
        {
            _demoService = demoService;
        }

        /// <summary>
        /// 生成实体类
        /// </summary>
        [AllowAnonymous]
        [HttpGet]
        public void CreateDbModels()
        {
            _demoService.CreateModel("wordlist_main");
        }

        /// <summary>
        /// 获取账号列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public PageResultModel<UserInfoModel> GetAccountList(GetAccountListRequest request)
        {
            var result = _demoService.GetAccountList(request);
            return result;
        }


        /// <summary>
        /// 导出账号列表
        /// </summary>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public ResultInfoModel ExportAccountList()
        {
            var result = _demoService.ExportAccountList();
            return result;
        }

        /// <summary>
        /// Ping测试
        /// </summary>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpGet]
        public string Ping()
        {
            return "Ping成功";
        }
    }
}